home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / digital_unix_bofs.txt < prev    next >
Encoding:
Internet Message Format  |  1999-03-24  |  7.8 KB

  1. Date: Fri, 19 Feb 1999 14:18:18 -0800
  2. From: Lamont Granquist <lamontg@RAVEN.GENOME.WASHINGTON.EDU>
  3. To: BUGTRAQ@netspace.org
  4. Subject: More Buffer Overflows in Digital Unix
  5.  
  6. 1. No return-into-libc exploit for Digital Unix
  7.  
  8.    I didn't understand the return-into-libc method really prior to my
  9.    previous BUGTRAQ post.  Since then, I understand it a bit more and
  10.    Solar Designer has informed me that such attacks will be very
  11.    difficult due to the passing of parameters in registers on this
  12.    architecture.  So, things look better for 3.x admins, although AFAIK
  13.    you can still just shove some shellcode into a buffer that gets
  14.    malloc()'d and then return into it.
  15.  
  16. 2. Incorrect patch installation instructions in SSRT0583U.tar.gz
  17.  
  18.    The initial patch installation instructions for SSRT0583U for 'at' and
  19.    'inc' had incorrect instructions which would leave exploitable suid
  20.    root binaries lying around if they were followed to the letter, e.g:
  21.  
  22.    # cp /patches/at at.new
  23.    # chown root:bin at.new
  24.    # chmod 4755 at.new
  25.    # ln at at.orig
  26.    # mv at.new at
  27.  
  28.    These were later changed to read:
  29.  
  30.    # cp /patches/at at.new
  31.    # chown root:bin at.new
  32.    # chmod 4755 at.new
  33.    # ln at at.orig
  34.    # mv at.new at
  35.    # chmod 400 at.orig
  36.  
  37.    The MD5 checksums on the patch files are/were:
  38.  
  39.    bf03f67cf0ec69e335ba9dcc0cf88c13  SSRT0583U.tar.gz (old)
  40.    d1da354134b0335548aa7f436414d94a  SSRT0583U.tar.gz (corrected)
  41.  
  42.    To be sure you're okay:
  43.  
  44.    # chmod 400 /usr/bin/at.orig /usr/bin/mh/inc.orig /usr/shlib/libmh.so.orig
  45.  
  46.    The patches are available at:
  47.  
  48.    ftp://xfer.service.digital.com/to_customer/SSRT0583U.tar.gz
  49.  
  50. 3. DIGITAL NetWorker for DIGITAL UNIX, Version 4.4
  51.  
  52.    There exists an exploitable buffer overflow in the program nsralist
  53.    which in version 4.4. is setuid root.  I have reports that the more
  54.    current 5.2 version does not install this program suid root.  To check
  55.    for this vulnerability:
  56.  
  57.    % ls -l /usr/opt/BRX440/BRXSOAKIT440/bin/nsralist
  58.    -rws--x--x   1 root     system    565248 Nov 26  1997 /usr/opt/BRX440/BRXSOAKIT440/bin/nsralist
  59.    % /usr/opt/BRX440/BRXSOAKIT440/bin/nsralist -R `perl -e 'print "a" x 4000'`
  60.    nsralist: RPC error, Program not registered
  61.    Segmentation fault
  62.  
  63.    The fix is to strip the suid root bits off of everything in that
  64.    directory, and to upgrade to version 5.2 or later.
  65.  
  66.    Obviously, "BRX440" contains the version number and other possibly
  67.    exploitable versions may be in different directories, so:
  68.  
  69.    % find /usr/opt -name nsralist -exec ls -la \{\} \;
  70.  
  71.    Or better just scan your entire machine for suid/sgid files.
  72.  
  73. 4. /usr/bin/rdist CA-96.14.rdist_vul
  74.  
  75.    This bug was apparently first described in CA-91.20.rdist.vulnerability,
  76.    then CA-94.04.SunOS.rdist.vulnerability and later in CA-96.14.rdist_vul.
  77.    This was a bug in common code which DEC apparently claimed to have
  78.    fixed with patches to OSF 3.2C and prior platforms and which should
  79.    have been included in all the 4.0 releases.  Unfortunately, 4.0D with
  80.    patch kit #3 still has this bug:
  81.  
  82.    % /usr/bin/rdist -d `perl -e 'print "a" x 300'` -d `perl -e 'print "a" x 300'`
  83.    rdist: line 1:
  84. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  85. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  86. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa redefined
  87.    Segmentation fault
  88.  
  89.    Luckily, this is difficult to exploit because the "..aaa redefined" is
  90.    what gets pushed onto the stack which means that either you jump to a
  91.    location in memory with no 0x00's or else you overwrite the ra with
  92.    the tail end of "redefined" which probably means 0x164656369 as the
  93.    most useful address and *I* cannot figure out how to get code into that
  94.    location.  This lets one mess around with the return address way too
  95.    much, though.  If anyone figures out how to exploit this please let me
  96.    know.
  97.  
  98.    Exploit code for this advisory on rootshell.com includes code for
  99.    IRIX (irix-buffer.txt 6/15/97 for 'ordist') and FreeBSD (rdist-ex.c
  100.    8/26/96).
  101.  
  102.    Thanks for suggesting this one goes out to minus- on #phrack
  103.  
  104. 5. /usr/bin/rdist CA-97.23.rdist
  105.  
  106.    In the CERT advisory on this subject, Digital claimed "This reported
  107.    problem is not present for Digital's ULTRIX or Digital UNIX Operating
  108.    Systems Software."  This is entirely inaccurate:
  109.  
  110.    % /usr/bin/rdist -d bleh=`perl -e 'print "a" x 8200'` -c /tmp/ '${bleh}'
  111.    rdist: line 1: Pathname too long
  112.    rdist: line 1: Pathname too long
  113.    rdist: line 1: Pathname too long
  114.    rdist: line 1: Pathname too long
  115.    rdist: line 1: Pathname too long
  116.    rdist: line 1: Pathname too long
  117.    rdist: line 1: Pathname too long
  118.    rdist: line 1: Pathname too long
  119.    rdist: line 1: Pathname too long
  120.    rdist: line 1: Pathname too long
  121.    Segmentation fault
  122.  
  123.    (again you need to do this from a reasonably recent version of tcsh
  124.    which will not choke on `perl -e 'print "a" x 8200'` with a "Word too
  125.    long" error)
  126.  
  127.    Exploitation of this bug is completely straight-forwards, although the
  128.    script that I included with /usr/bin/mh/inc will need to be modified.
  129.    This buffer overflow exists on all version of Digital Unix from 4.0
  130.    up through 4.0D with patch kit #3.  Digital is aware of this problem
  131.    and is working on patches, but I strongly suggest that admins take
  132.    the suggestions offered in the CERT advisory CA-97.23.rdist:
  133.  
  134.    1. strip the suid root bits off of /usr/bin/rdist
  135.    2. install the rdist version from http://www.magnicomp.com/rdist/
  136.       which does not run suid root (www.magnicomp.com is the new home
  137.       of the supported version of rdist which used to be at USC).
  138.  
  139.    Exploit code for this advisory in the BUGTRAQ archives includes
  140.    code for Solaris 2.5-2.6 and is at:
  141.  
  142.    http://geek-girl.com/bugtraq/1998_3/0522.html
  143.  
  144.    Thanks for this one go out to minus- on #phrack and _daveg_ for
  145.    reminding me after i'd gotten all frustrated over CA-96.14 that
  146.    there was a 2nd CERT advisory on rdist and for digging up the Solaris
  147.    exploit for me.
  148.  
  149. 6. Exploit code
  150.  
  151.    Sorry.  No exploit code for the script kiddies this time.  Exploitation
  152.    of #3 and #5 are entirely-straight forwards.  If anyone (CERT???) needs
  153.    exploit code for legitimate testing purposes, just send me e-mail.
  154.  
  155. 7. Patches
  156.  
  157.    Compaq has been made aware of the problem.  Patches should be
  158.    forthcoming.  Admins are, however, advised not to wait for the
  159.    patches.  NetWorker should be upgraded or the suid root bits
  160.    stripped off of it (this might impair functionality, contact Compaq
  161.    if you really need to know if you can do this) and the publically
  162.    available non-suid rdist version should be used in place of the suid
  163.    root one provided with Digital Unix.
  164.  
  165.    Yes I released this prior to the patches being made available.  I
  166.    do so because entirely satisfactory work-arounds exist, in fact
  167.    "work-arounds" exist which are ultimately better than any patch that
  168.    Compaq releases which still keeps rdist suid root.  The only way
  169.    Compaq could come out with something better would be to develop a
  170.    non-exec-stack work-around for 4.0 or to distribute privaleged
  171.    code binaries which had been compiled with something like StackGuard.
  172.    Unfortunately, I don't see Compaq doing this.
  173.  
  174. 8. Reminder
  175.  
  176.    There are undoubtably many buffer overflows still to be found in
  177.    Digital Unix.  Reduce your privaleged code to a minimum:
  178.  
  179.    a. find all suid/sgid programs, strip the ones that aren't used and
  180.       wrap the ones that are.
  181.    b. hunt down all daemon processes and turn off the ones that you don't
  182.       use -- use nmap, netstat -an and lsof.
  183.  
  184. --
  185. Lamont Granquist                       lamontg@raven.genome.washington.edu
  186. Dept. of Molecular Biotechnology       (206)616-5735  fax: (206)685-7344
  187. Box 352145 / University of Washington / Seattle, WA 98195
  188. PGP pubkey: finger lamontg@raven.genome.washington.edu | pgp -fka
  189.  
  190.